import Vue from 'vue';
import message from './alert';

const VueMessage = Vue.extend(message);
function createMessage(opt) {
  const vm = new VueMessage({
    data() {
      return {
        message: opt.message || '这是默认提示',
        duration: opt.duration,
        type: opt.type,
        center: opt.center,
      };
    },
  });
  vm.$mount();
  document.body.appendChild(vm.$el);
}

export default {
  install(_) {
    /* eslint-disable no-param-reassign */
    _.prototype.$message = createMessage;
  },
};
